package qidian.it.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import qidian.it.entity.Result;
import qidian.it.entity.User;
import qidian.it.mapper.UserMapper;
import qidian.it.openfeign.ProductOpenFeign;
import javax.annotation.Resource;

@RestController
public class UserController {
    @Resource
    UserMapper userMapper;


    @Autowired
    ProductOpenFeign productOpenFeign;



    @RequestMapping("/info")
    public Result userInfo(){
        return Result.success(userMapper.selectByPrimaryKey(1));
    }

    @RequestMapping("/productInfo")
    public Result productInfo(){
        return productOpenFeign.productInfo();
    }

    @RequestMapping("/productName")
    public Result getProductName(String productName){
        System.out.println(productName);
        return productOpenFeign.getProductName(productName);
    }

    @RequestMapping("/getUserInfo")
    public Result getUserInfo(){
        User user=new User();
        user.setUserId(1001);
        user.setPassword("123456");
        user.setUsername("admin");
        return productOpenFeign.getUserInfo(user);
    }

}
